Skip to content

Conversation

@CorentinDeBoisset
Copy link
Contributor

When we measure the size of the autosize textarea, we make it temporarily smaller which can cause the scroll position to shift. These changes add a workaround that assign a temporary margin-bottom while measuring.

Fixes #23834

@mmalerba
Copy link
Contributor

mmalerba commented Jan 5, 2026

reassigning to @crisbeto since he was the author of the firefox-specific fix

@mmalerba mmalerba requested a review from crisbeto January 5, 2026 20:07
const element = this._textareaElement;
const previousMargin = element.style.marginBottom || '';
const isFirefox = this._platform.FIREFOX;
const needsMarginFiller = isFirefox && this._hasFocus;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need the _hasFocus part of this check. Otherwise we'll end up applying the margin on elements the user isn't interacting with.

When we measure the size of the autosize textarea, we make it temporarily smaller which can cause the scroll position to shift. These changes add a workaround that assign a temporary margin-bottom while measuring.

Fixes angular#23834
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jan 13, 2026
@crisbeto crisbeto merged commit c62c64f into angular:main Jan 13, 2026
10 of 12 checks passed
@crisbeto
Copy link
Member

This PR was merged into the repository. The changes were merged into the following branches:

crisbeto pushed a commit that referenced this pull request Jan 13, 2026
When we measure the size of the autosize textarea, we make it temporarily smaller which can cause the scroll position to shift. These changes add a workaround that assign a temporary margin-bottom while measuring.

Fixes #23834

(cherry picked from commit c62c64f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: cdk/text-field target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(cdkTextareaAutosize): autosize scrolls parent to top at each key hit with ngZoneEventCoalescing enabled

3 participants